#pragma once

class DummyHandler : public ACE_Handler
{
	typedef ACE_Handler super;
	typedef std::map<uint16, SvcHandler<DummyHandler> > ServiceRegister;

public:
	DummyHandler();
	~DummyHandler(void);

	int open();
	void close();
	void make_name();

	ACE_HANDLE handle() const;
	void handle(ACE_HANDLE handle);

	bool connect();
	bool initiate_read_stream();

	const int user_index() const { return user_index_; }
	const char* user_name() const { return user_name_.c_str(); }

	bool send(PacketData& data);
	bool send_connect_auth();
	int send_random_chat();
	
	int recv_chat_start(PacketData& data);
	int recv_connect_auth(PacketData& data);
	int recv_chat_message(PacketData& data);
	int recv_packet_parsing(ACE_Message_Block& mb);

	virtual void handle_read_stream(const ACE_Asynch_Read_Stream::Result &result);
	virtual void handle_write_stream(const ACE_Asynch_Read_Stream::Result &result);
	virtual void handle_time_out(const ACE_Time_Value& current_time, const void* act);


private:
	ACE_SOCK_Stream stream_;    
	ACE_Asynch_Read_Stream reader_;
	ACE_Asynch_Write_Stream writer_;
	
	int user_index_;
	std::string user_name_;
	bool connected_;
	ServiceRegister svc_handler_;
};

#define REGISTR_HANDLER(code, handler) \
	svc_handler_[code] = SvcHandler<DummyHandler>(&handler)